<template>
  <div class="test">
    <div class="out" @click="handleOut">
      <div class="in" @click="handleIn">1</div>
      <!-- 内置的$event对象，一般用于传递event和具体的值 -->
      <!-- <div class="in" @click="handleIn($event)">2</div> -->
      <div class="in" @click.stop="handleIn">2</div>
    </div>

    <a @click="goBaidu" href="https://baidu.com">去百度</a>
    <a @click.prevent="goBaidu" href="https://baidu.com">去百度</a>
    <a @click.prevent.once="goBaidu" href="https://baidu.com">只想阻止一次</a>
  </div>
</template>

<script>
export default {
  data() {
    return {}
  },
  methods: {
    handleOut() {
      console.log('handleOut')
    },
    handleIn(event) {
      console.log('handleIn')
      // 原生js写法
      // event.stopPropagation()
    },
    goBaidu(event) {
      console.log('goBaidu')
      // 原生js写法
      // event.preventDefault()
    }
  }
}
</script>
<style lang="scss">
.out {
  width: 100px;
  height: 100px;
  background-color: pink;
  .in {
    width: 50px;
    height: 50px;
    background-color: red;
  }
}
</style>
